home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / baswiz17.zip / CALC.BAS < prev    next >
BASIC Source File  |  1991-09-21  |  1KB  |  38 lines

  1. '   +----------------------------------------------------------------------+
  2. '   |                                                                      |
  3. '   |        BASWIZ  Copyright (c) 1990-1991  Thomas G. Hanlin III         |
  4. '   |                                                                      |
  5. '   |                      The BASIC Wizard's Library                      |
  6. '   |                                                                      |
  7. '   +----------------------------------------------------------------------+
  8.  
  9.    DECLARE SUB Evaluate (Expression$, Result!, ErrCode%)
  10.  
  11.    DEFINT A-Z
  12.  
  13.    Expr$ = COMMAND$
  14.  
  15.    Evaluate Expr$, Result!, ErrCode
  16.  
  17.    SELECT CASE ErrCode
  18.       CASE 0
  19.          PRINT Expr$; " =";
  20.          IF ABS(Result!) = Result! THEN
  21.             PRINT Result!
  22.          ELSE
  23.             PRINT " "; Result!
  24.          END IF
  25.       CASE 2
  26.          PRINT "Missing number"
  27.       CASE 4
  28.          PRINT "Unbalanced parentheses"
  29.       CASE 8
  30.          PRINT "CALC  Copyright (c) 1990-1991  Thomas G. Hanlin III"
  31.          PRINT "   Syntax : CALC numeric expression"
  32.          PRINT "   Example: CALC 2+3*4
  33.       CASE 9
  34.          PRINT "Division by zero"
  35.       CASE ELSE
  36.          PRINT "Error"
  37.    END SELECT
  38.